package com.zenith.article.controller;

import com.zenith.article.po.domain.ArtInteraction;
import com.zenith.article.service.ArtInteractionService;
import com.zenith.common.annotation.request.SecurePostMapping;
import com.zenith.common.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 文章互动控制器
 *
 * @author zenith
 * @since 2025-08-29
 */
@RestController
@RequestMapping("/api/article/interaction")
@Tag(name = "文章互动管理", description = "文章互动相关接口（点赞、收藏、分享等）")
public class ArtInteractionController {

    @Autowired
    private ArtInteractionService artInteractionService;

    /**
     * 创建文章互动（点赞、收藏、分享等）
     */
    @Operation(summary = "创建文章互动")
    @SecurePostMapping("/createArtInteraction")
    public Result<Boolean> createArtInteraction(@RequestBody ArtInteraction interaction) {
        boolean result = artInteractionService.save(interaction);
        return Result.success(result);
    }

    /**
     * 删除文章互动
     */
    @Operation(summary = "删除文章互动")
    @SecurePostMapping("/deleteArtInteraction/{id}")
    public Result<Boolean> deleteArtInteraction(@PathVariable Long id) {
        boolean result = artInteractionService.removeById(id);
        return Result.success(result);
    }
}